package service;

import dao.TeacherDAO;
import domain.Student;
import domain.Teacher;

import java.util.List;

/**
 * @author 杨森
 * @date 2022年11月28日 20:13
 */
public class TeacherService {
    private TeacherDAO teacherDAO= new TeacherDAO();

    //通过教师的名字和密码登录
    public Teacher getTeacherByNameAndPwd(String t_name,String t_pwd){
        return (Teacher) teacherDAO.querySingle("select * from teacher where t_name=? and t_pwd=md5(?) ",Teacher.class,t_name,t_pwd);
    }

    //返回教师列表
    public List<Teacher> list(){
        return teacherDAO.queryMulti("select * from teacher",Teacher.class);
    }


    //获取id
    public int get_id(String t_name){
        return (int) teacherDAO.queryScalar("select t_id from teacher where t_name=?",t_name);
    }
}
